from scapy.all import *
import threading

class SourceRouting(Packet):
    name = "SourceRouting"
    fields_desc = [
        ByteField("current_index", 0),
        ByteField("path_len", 3),
        ByteField("port0", 4),
        ByteField("port2", 2),
        ByteField("port3", 0)
    ]

def send_ipv4():
    while True:
        pkt = Ether(type=0x800)/IP(dst="10.0.2.2")/Raw("IPv4 Traffic")
        sendp(pkt, iface="eth0", verbose=False)
        print("Sent packet ")
        time.sleep(0.45)

def send_ipv6():
    while True:
        pkt = Ether(type=0x86DD)/IPv6(dst="fe80::5678")/Raw("IPv6 Traffic")
        sendp(pkt, iface="eth0", verbose=False)
        print("Sent packet ")
        time.sleep(0.5)

def send_sr():
    while True:
        pkt = Ether(type=0x1234)/SourceRouting()/Raw("SR Traffic")
        sendp(pkt, iface="eth0", verbose=False)
        print("Sent packet ")
        time.sleep(0.5)

if __name__ == "__main__":

    threads = [
        threading.Thread(target=send_ipv4),
        threading.Thread(target=send_ipv6),
        threading.Thread(target=send_sr)
    ]
    for t in threads:
        t.start()
    for t in threads:
        t.join()
